/*
 * BonPlan.java
 *
 * Created on 11 janvier 2008, 04:24
 */
package com.reimscopie ;

import java.util.* ;


/**
 * This value is a Bon plan !
 */
public class BonPlan extends Value {
  
  // the product
  private Product product ;
  
  // end date
  private Date end ;
  
  // price factor
  private int factor ;
  
  
  /**
   * Create a new <code>BonPlan</code> instance with all attributes. This
   * object no image in the database.
   *
   * @param product The product.
   * @param end The end date.
   * @param factor The price factor.
   */
  public BonPlan(Product product,Date end,int factor) {
    
    super() ;
    
    this.product = product ;
    this.end     = end ;
    this.factor  = factor ;
    
  }
  
  
  /**
   * Create a new instance of <code>BonPlan</code> with an image in the
   * database.
   *
   * @param id The bon-plan id in the database.
   * @param product The product.
   * @param end The end date.
   * @param factor The price factor.
   */
  public BonPlan(long id,Product product,Date end,int factor) {
    
    super(id) ;
    
    this.product = product ;
    this.end     = end ;
    this.factor  = factor ;
    
  }
  
  
  /**
   * Return the product of this bon plan.
   *
   * @return The product.
   */
  public Product getProduct() {
    return product ;
  }
  
  
  /**
   * Return the end date of this bon plan.
   *
   * @return The end date.
   */
  public Date getEndDate() {
    return end ;
  }
  
  
  /**
   * Return the price factor of this bon plan.
   *
   * @return The price factor.
   */
  public int getFactor() {
    return factor ;
  }
  
  
  /**
   * Create a new map with all attributes of this value.
   * 
   * @return A string-string map with the named attributes.
   */
  @Override
  public Map<String,String> toMap() {
    
    Map<String,String> map = new LinkedHashMap<String,String>() ;
    
    map.put("product",product.toString()) ;
    map.put("end",end.toString()) ;
    map.put("factor",String.valueOf(factor)) ;
    
    return map ;
    
  }
  
}
